﻿/**
*	Singleton Data Model on client side to hold global 
* 	variables.
* 
* 	By Jie Gao, May 2009
* 
*/

package com.uprr.app.tnm.model
{
    import mx.collections.ArrayCollection;
	import mx.controls.*;
	import com.esri.ags.Graphic;
	
	import com.esri.ags.Map;
    import com.esri.ags.layers.*;
	
    public class Model
    {
        
		public var arrcol : ArrayCollection = new ArrayCollection();
		
		// icon urls for map layer icons
		[Bindable]
		public var layerIcons:Array=new Array();	
		//public var layerIcons:ArrayCollection=new ArrayCollection();	
		
		[Bindable]
		public var map:Map;
		
		[Bindable]
		public var graphicsLayer:GraphicsLayer;
		
		// map services
		[Bindable (event="ServiceListUpdate")]  
		public var serviceList : ArrayCollection=new ArrayCollection();
		
		// bookmarks
		[Bindable (event='BookmarkListUpdate')]
		public var bkmkList : ArrayCollection = new ArrayCollection();
		
		// tasks
		[Bindable (event='TaskListUpdate')]
		public var taskList : ArrayCollection=new ArrayCollection();
		
		// show current location for train schedule
		public var curCirc7: String=new String();
		
        // Info Layer id
		[Bindable]
		public var infoLayerId : int;

		// Info Layer Name
		[Bindable]
		public var infoLayerName : String;
		
		
		[Bindable]
		public var layerFields:Array;
		
 
		[Bindable]
		public var searchResultBuffer:ArrayCollection=new ArrayCollection();
	 
		
		// overlay map service path
		[Bindable]
		public var overlayMapServiceHost:String;
		
		[Bindable]
		public var overlayMapServiceFolder:String;
		
		[Bindable]
		public var overlayMapServiceName:String;
		
		[Bindable]
		public var overlayMapId:int;
		
		[Bindable]
		public var layerNames:Array;
		
		// street and satellite alpha mixing rates
		[Bindable]
		public var mixerValue:Number=0;
		
		[Bindable]
		public var distance:String = "";
		[Bindable]
		public var graphicToRemove:Graphic;
 	 
		/*
		*  Constructor - always return the singleton reference 
		*/
        public function Model( singletonEnforcer : SingletonEnforcer)
        {
			// does nothing
		}
        
        private static var m_instance : Model;
        
		// singleton model instance
        public static function getInstance() : Model
        {
            if( m_instance == null )
            {
                m_instance = new Model( new SingletonEnforcer());
            }
            return m_instance;
        }

		
	}
}

/*
*	Enfore Singleton instantiation 
*/

class SingletonEnforcer
{    
}